import AnimatedObject from '../base/animated_object';

/**
 * 植物基类
 * 所有具体植物类型的父类
 */
export default class Plant extends AnimatedObject {
  constructor(imgPrefix, frameCount = 1, width = 0, height = 0, frameInterval = 5, x = 0, y = 0, resourceLoader = null) {
    super(imgPrefix, frameCount, width, height, frameInterval, x, y, resourceLoader);
    this.health = 100; // 植物生命值
    this.isAlive = true; // 是否存活
  }



  /**
   * 植物受伤
   */
  takeDamage(damage) {
    this.health -= damage;
    if (this.health <= 0) {
      this.isAlive = false;
    }
  }
}